package me.kagami.exex.util;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ClassUtil {

	private static void collectFields(Class<?> beanClass, List<Field> fields) {
		if (!beanClass.getName().equals("java.lang.Object")) {
			Field[] superFields = beanClass.getDeclaredFields();
			fields.addAll(Arrays.asList(superFields));
			collectFields(beanClass.getSuperclass(), fields);
		}
	}

	public static List<Field> getFieldsList(Object bean) {
		List<Field> fields = new ArrayList<Field>();
		collectFields(bean.getClass(), fields);
		return fields;
	}

}
